home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / man / man.n / Tcl.n < prev    next >
Text File  |  1995-07-17  |  12KB  |  387 lines

  1. '\"
  2. '\" Copyright (c) 1993 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/tcl/man/RCS/Tcl.n,v 1.118 93/07/28 14:13:25 ouster Exp $ SPRITE (Berkeley)
  22. '
  23. .\" The definitions below are for supplemental macros used in Tcl/Tk
  24. .\" manual entries.
  25. .\"
  26. .\" .HS name section [date [version]]
  27. .\"    Replacement for .TH in other man pages.  See below for valid
  28. .\"    section names.
  29. .\"
  30. .\" .AP type name in/out [indent]
  31. .\"    Start paragraph describing an argument to a library procedure.
  32. .\"    type is type of argument (int, etc.), in/out is either "in", "out",
  33. .\"    or "in/out" to describe whether procedure reads or modifies arg,
  34. .\"    and indent is equivalent to second arg of .IP (shouldn't ever be
  35. .\"    needed;  use .AS below instead)
  36. .\"
  37. .\" .AS [type [name]]
  38. .\"    Give maximum sizes of arguments for setting tab stops.  Type and
  39. .\"    name are examples of largest possible arguments that will be passed
  40. .\"    to .AP later.  If args are omitted, default tab stops are used.
  41. .\"
  42. .\" .BS
  43. .\"    Start box enclosure.  From here until next .BE, everything will be
  44. .\"    enclosed in one large box.
  45. .\"
  46. .\" .BE
  47. .\"    End of box enclosure.
  48. .\"
  49. .\" .VS
  50. .\"    Begin vertical sidebar, for use in marking newly-changed parts
  51. .\"    of man pages.
  52. .\"
  53. .\" .VE
  54. .\"    End of vertical sidebar.
  55. .\"
  56. .\" .DS
  57. .\"    Begin an indented unfilled display.
  58. .\"
  59. .\" .DE
  60. .\"    End of indented unfilled display.
  61. .\"
  62. '\"    # Heading for Tcl/Tk man pages
  63. .de HS
  64. .ds ^3 \\0
  65. .if !"\\$3"" .ds ^3 \\$3
  66. .if '\\$2'cmds'       .TH \\$1 1 \\*(^3 \\$4
  67. .if '\\$2'lib'        .TH \\$1 3 \\*(^3 \\$4
  68. .if '\\$2'tcl'        .TH \\$1 n \\*(^3 Tcl "Tcl Built-In Commands"
  69. .if '\\$2'tk'         .TH \\$1 n \\*(^3 Tk "Tk Commands"
  70. .if '\\$2'tclc'        .TH \\$1 3 \\*(^3 Tcl "Tcl Library Procedures"
  71. .if '\\$2'tkc'         .TH \\$1 3 \\*(^3 Tk "Tk Library Procedures"
  72. .if '\\$2'tclcmds'         .TH \\$1 1 \\*(^3 Tk "Tcl Applications"
  73. .if '\\$2'tkcmds'         .TH \\$1 1 \\*(^3 Tk "Tk Applications"
  74. .if t .wh -1.3i ^B
  75. .nr ^l \\n(.l
  76. .ad b
  77. ..
  78. '\"    # Start an argument description
  79. .de AP
  80. .ie !"\\$4"" .TP \\$4
  81. .el \{\
  82. .   ie !"\\$2"" .TP \\n()Cu
  83. .   el          .TP 15
  84. .\}
  85. .ie !"\\$3"" \{\
  86. .ta \\n()Au \\n()Bu
  87. \&\\$1    \\fI\\$2\\fP    (\\$3)
  88. .\".b
  89. .\}
  90. .el \{\
  91. .br
  92. .ie !"\\$2"" \{\
  93. \&\\$1    \\fI\\$2\\fP
  94. .\}
  95. .el \{\
  96. \&\\fI\\$1\\fP
  97. .\}
  98. .\}
  99. ..
  100. '\"    # define tabbing values for .AP
  101. .de AS
  102. .nr )A 10n
  103. .if !"\\$1"" .nr )A \\w'\\$1'u+3n
  104. .nr )B \\n()Au+15n
  105. .\"
  106. .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
  107. .nr )C \\n()Bu+\\w'(in/out)'u+2n
  108. ..
  109. '\"    # BS - start boxed text
  110. '\"    # ^y = starting y location
  111. '\"    # ^b = 1
  112. .de BS
  113. .br
  114. .mk ^y
  115. .nr ^b 1u
  116. .if n .nf
  117. .if n .ti 0
  118. .if n \l'\\n(.lu\(ul'
  119. .if n .fi
  120. ..
  121. '\"    # BE - end boxed text (draw box now)
  122. .de BE
  123. .nf
  124. .ti 0
  125. .mk ^t
  126. .ie n \l'\\n(^lu\(ul'
  127. .el \{\
  128. .\"    Draw four-sided box normally, but don't draw top of
  129. .\"    box if the box started on an earlier page.
  130. .ie !\\n(^b-1 \{\
  131. \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  132. .\}
  133. .el \}\
  134. \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  135. .\}
  136. .\}
  137. .fi
  138. .br
  139. .nr ^b 0
  140. ..
  141. '\"    # VS - start vertical sidebar
  142. '\"    # ^Y = starting y location
  143. '\"    # ^v = 1 (for troff;  for nroff this doesn't matter)
  144. .de VS
  145. .mk ^Y
  146. .ie n 'mc \s12\(br\s0
  147. .el .nr ^v 1u
  148. ..
  149. '\"    # VE - end of vertical sidebar
  150. .de VE
  151. .ie n 'mc
  152. .el \{\
  153. .ev 2
  154. .nf
  155. .ti 0
  156. .mk ^t
  157. \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
  158. .sp -1
  159. .fi
  160. .ev
  161. .\}
  162. .nr ^v 0
  163. ..
  164. '\"    # Special macro to handle page bottom:  finish off current
  165. '\"    # box/sidebar if in box/sidebar mode, then invoked standard
  166. '\"    # page bottom macro.
  167. .de ^B
  168. .ev 2
  169. 'ti 0
  170. 'nf
  171. .mk ^t
  172. .if \\n(^b \{\
  173. .\"    Draw three-sided box if this is the box's first page,
  174. .\"    draw two sides but no top otherwise.
  175. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  176. .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  177. .\}
  178. .if \\n(^v \{\
  179. .nr ^x \\n(^tu+1v-\\n(^Yu
  180. \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
  181. .\}
  182. .bp
  183. 'fi
  184. .ev
  185. .if \\n(^b \{\
  186. .mk ^y
  187. .nr ^b 2
  188. .\}
  189. .if \\n(^v \{\
  190. .mk ^Y
  191. .\}
  192. ..
  193. '\"    # DS - begin display
  194. .de DS
  195. .RS
  196. .nf
  197. .sp
  198. ..
  199. '\"    # DE - end display
  200. .de DE
  201. .fi
  202. .RE
  203. .sp .5
  204. ..
  205. .de UL
  206. \\$1\l'|0\(ul'\\$2
  207. ..
  208. .HS Tcl tcl
  209. .BS
  210. .SH NAME
  211. Tcl \- Summary of Tcl language syntax.
  212. .BE
  213.  
  214. .SH DESCRIPTION
  215. .LP
  216. The following rules define the syntax and semantics of the Tcl language:
  217. .IP [1]
  218. A Tcl script is a string containing one or more commands.
  219. Semi-colons and newlines are command separators unless quoted as
  220. described below.
  221. Close brackets are command terminators during command substitution
  222. (see below) unless quoted.
  223. .IP [2]
  224. A command is evaluated in two steps.
  225. First, the Tcl interpreter breaks the command into \fIwords\fR
  226. and performs substitutions as described below.
  227. These substitutions are performed in the same way for all
  228. commands.
  229. The first word is used to locate a command procedure to
  230. carry out the command, then all of the words of the command are
  231. passed to the command procedure.
  232. The command procedure is free to interpret each of its words
  233. in any way it likes, such as an integer, variable name, list,
  234. or Tcl script.
  235. Different commands interpret their words differently.
  236. .IP [3]
  237. Words of a command are separated by white space (except for
  238. newlines, which are command separators).
  239. .IP [4]
  240. If the first character of a word is double-quote (``"'') then
  241. the word is terminated by the next double-quote character.
  242. If semi-colons, close brackets, or white space characters
  243. (including newlines) appear between the quotes then they are treated
  244. as ordinary characters and included in the word.
  245. Command substitution, variable substitution, and backslash substitution
  246. are performed on the characters between the quotes as described below.
  247. The double-quotes are not retained as part of the word.
  248. .IP [5]
  249. If the first character of a word is an open brace (``{'') then
  250. the word is terminated by the matching close brace (``}'').
  251. Braces nest within the word: for each additional open
  252. brace there must be an additional close brace (however,
  253. if an open brace or close brace within the word is
  254. quoted with a backslash then it is not counted in locating the
  255. matching close brace).
  256. No substitutions are performed on the characters between the
  257. braces except for backslash-newline substitutions described
  258. below, nor do semi-colons, newlines, close brackets,
  259. or white space receive any special interpretation.
  260. The word will consist of exactly the characters between the
  261. outer braces, not including the braces themselves.
  262. .IP [6]
  263. If a word contains an open bracket (``['') then Tcl performs
  264. \fIcommand substitution\fR.
  265. To do this it invokes the Tcl interpreter recursively to process
  266. the characters following the open bracket as a Tcl script.
  267. The script may contain any number of commands and must be terminated
  268. by a close bracket (``]'').
  269. The result of the script (i.e. the result of its last command) is
  270. substituted into the word in place of the brackets and all of the
  271. characters between them.
  272. There may be any number of command substitutions in a single word.
  273. Command substitution is not performed on words enclosed in braces.
  274. .IP [7]
  275. If a word contains a dollar-sign (``$'') then Tcl performs \fIvariable
  276. substitution\fR:  the dollar-sign and the following characters are
  277. replaced in the word by the value of a variable.
  278. Variable substition may take any of the following forms:
  279. .RS
  280. .TP 15
  281. \fB$\fIname\fR
  282. \fIName\fR is the name of a scalar variable;  the name is terminated
  283. by any character that isn't a letter, digit, or underscore.
  284. .TP 15
  285. \fB$\fIname\fB(\fIindex\fB)\fR
  286. \fIName\fR gives the name of an array variable and \fIindex\fR gives
  287. the name of an element within that array.
  288. \fIName\fR must contain only letters, digits, and underscores.
  289. Command substitutions, variable substitutions, and backslash
  290. substitutions are performed on the characters of \fIindex\fR.
  291. .TP 15
  292. \fB${\fIname\fB}\fR
  293. \fIName\fR is the name of a scalar variable.  It may contain any
  294. characters whatsoever except for close braces.
  295. .RE
  296. .LP
  297. There may be any number of variable substitutions in a single word.
  298. Variable substitution is not performed on words enclosed in braces.
  299. .IP [8]
  300. If a backslash (``\e'') appears within a word then
  301. \fIbackslash substitution\fR occurs.
  302. .VS
  303. In all cases but those described below the backslash is dropped and
  304. the following character is treated as an ordinary
  305. character and included in the word.
  306. .VE
  307. This allows characters such as double quotes, close brackets,
  308. and dollar signs to be included in words without triggering
  309. special processing.
  310. The following table lists the backslash sequences that are
  311. handled specially, along with the value that replaces each sequence.
  312. .RS
  313. .VS
  314. .TP 6
  315. \e\fBa\fR
  316. Audible alert (bell) (0x7).
  317. .VE
  318. .TP 6
  319. \e\fBb\fR
  320. Backspace (0x8).
  321. .TP 6
  322. \e\fBf\fR
  323. Form feed (0xc).
  324. .TP 6
  325. \e\fBn\fR
  326. Newline (0xa).
  327. .TP 6
  328. \e\fBr\fR
  329. Carriage-return (0xd).
  330. .TP 6
  331. \e\fBt\fR
  332. Tab (0x9).
  333. .TP 6
  334. \e\fBv\fR
  335. Vertical tab (0xb).
  336. .TP 6
  337. \e\fB<newline>\fIwhiteSpace\fR\fR
  338. .VS
  339. A single space character replaces the backslash, newline, and all
  340. white space after the newline.
  341. This backslash sequence is unique in that it is replaced in a separate
  342. pre-pass before the command is actually parsed.
  343. This means that it will be replaced even when it occurs between
  344. braces, and the resulting space will be treated as a word separator
  345. if it isn't in braces or quotes.
  346. .VE
  347. .TP 6
  348. \e\e
  349. Backslash (``\e'').
  350. .TP 6
  351. \e\fIooo\fR
  352. The digits \fIooo\fR (one, two, or three of them) give the octal value of
  353. the character.
  354. .TP 6
  355. \e\fBx\fIhh\fR
  356. .VS
  357. The hexadecimal digits \fIhh\fR give the hexadecimal value of
  358. the character.  Any number of digits may be present.
  359. .VE
  360. .RE
  361. .LP
  362. Backslash substitution is not performed on words enclosed in braces,
  363. except for backslash-newline as described above.
  364. .IP [9]
  365. If a hash character (``#'') appears at a point where Tcl is
  366. expecting the first character of the first word of a command,
  367. then the hash character and the characters that follow it, up
  368. through the next newline, are treated as a comment and ignored.
  369. The comment character only has significance when it appears
  370. at the beginning of a command.
  371. .IP [10]
  372. Each character is processed exactly once by the Tcl interpreter
  373. as part of creating the words of a command.
  374. For example, if variable substition occurs then no further
  375. substitions are performed on the value of the variable;  the
  376. value is inserted into the word verbatim.
  377. If command substitution occurs then the nested command is
  378. processed entirely by the recursive call to the Tcl interpreter;
  379. no substitutions are perfomed before making the recursive
  380. call and no additional substitutions are performed on the result
  381. of the nested script.
  382. .IP [11]
  383. Substitutions do not affect the word boundaries of a command.
  384. For example, during variable substitution the entire value of
  385. the variable becomes part of a single word, even if the variable's
  386. value contains spaces.
  387.